<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml"> 
 
<head> 
	<meta http-equiv="Content-type" content="text/html; charset=utf-8" /> 
	<title>湖南省自来水公司营销管理信息系统</title> 
	
	<link rel="stylesheet" href="../css/reset.css" type="text/css" media="screen" title="no title" />
	<link rel="stylesheet" href="../css/text.css" type="text/css" media="screen" title="no title" />
	<link rel="stylesheet" href="../css/form.css" type="text/css" media="screen" title="no title" />
	<link rel="stylesheet" href="../css/buttons.css" type="text/css" media="screen" title="no title" />
	<link rel="stylesheet" href="../css/grid.css" type="text/css" media="screen" title="no title" />	
	<link rel="stylesheet" href="../css/layout.css" type="text/css" media="screen" title="no title" />	
	
	<link rel="stylesheet" href="../css/ui-darkness/jquery-ui-1.8.12.custom.css" type="text/css" media="screen" title="no title" />
	<link rel="stylesheet" href="../css/plugin/jquery.visualize.css" type="text/css" media="screen" title="no title" />
	<link rel="stylesheet" href="../css/plugin/facebox.css" type="text/css" media="screen" title="no title" />
	<link rel="stylesheet" href="../css/plugin/uniform.default.css" type="text/css" media="screen" title="no title" />
	<link rel="stylesheet" href="../css/plugin/dataTables.css" type="text/css" media="screen" title="no title" />
	
	<link rel="stylesheet" href="../css/custom.css" type="text/css" media="screen" title="no title">

</head> 
 
<body> 

<div id="wrapper">
	
		
<div id="bool"></div>
	<div id="content" class="xgrid">
	
		<div class="x12">
			
			<h2>流程配置</h2>
			
			<p><button class="btn" @click="baochun()"><span></span>保存配置</button></p>
				
			<table class="data display">
			<thead>
				<tr>
					<th width="80">序号</th>
					<th width="120">流程工作项</th>
					<th>负责部门</th>
					<th></th>
				</tr>
			</thead>
			<tbody>
				<tr class="odd" v-for="flow in Syflow" v-if="flow.id>0">
					<td v-text="flow.id"></td>
					<td v-text="flow.stepName"></td>
					<td><select :id="flow.id"  @change="update(flow.id)">
                        <option v-for="de in SyDepts" :value="de.id"   :selected="de.id==flow.DeptID?'selected':''"  selected="selected">{{de.deptName}}</option>
                    </select></td>
					<td></td>
				</tr>
			</tbody>
			</table>
			
		</div> <!-- .x12 -->
		
	</div> <!-- #content -->
	
	<div id="footer">		
		<div class="content_pad">			
			<p>&copy; 2013-11 版权所有 <a href="#">湖南省自来水公司</a>.   技术支持 <a href="#">职业教育</a>.</p>
		</div> <!-- .content_pad -->
	</div> <!-- #footer -->
	
</div> <!-- #wrapper -->

<script src="../js/jquery/jquery-1.5.2.min.js"></script>
<script src="../js/jquery/jquery-ui-1.8.12.custom.min.js"></script>
<script src="../js/misc/excanvas.min.js"></script>
<script src="../js/jquery/facebox.js"></script>
<script src="../js/jquery/jquery.visualize.js"></script>
<script src="../js/jquery/jquery.dataTables.min.js"></script>
<script src="../js/jquery/jquery.tablesorter.min.js"></script>
<script src="../js/jquery/jquery.uniform.min.js"></script>
<script src="../js/jquery/jquery.placeholder.min.js"></script>

<script src="../js/widgets.js"></script>
<script src="../js/dashboard.js"></script>
<script src="../js/vue.js"></script>
<script type="text/javascript">
    var i=0;
    $(document).ready ( function ()
    {
        Dashboard.init ();
    });
    function  load() {
        $.getJSON("../Sydept/queryall",{},function(json){
            app.SyDepts=json;
            $.getJSON("../Sydept/query_flow",{},function(json){
                app.Syflow=json;
            });
        });
    }
    var app = new Vue({
        el:"#wrapper",
        data:{
            SyDepts:'',
            Syflow:'',
            flow:[{},{},{},{},{},{},{},{}],
        },
        methods:{
            update(id){
                var a=1;
                $.each(app.flow,function(){
                     if(this.id==id){
                     this.deptid = $("#"+id).val();
                     a++;
                    }
                });
                if(a==1){
                    app.flow[i].id=id;
                    app.flow[i].deptid=$("#"+id).val();
                    i++;
                }
            },
            baochun(){
                var uio=0;
                $.each(app.flow,function() {
                    if(this.id!=null){
                    $.getJSON("../Sydept/update_flow",{"id":this.id,"deptid":this.deptid}, function (json) {
                        if (json == 1) {

                            if(uio==0){
                                uio++;
                            alert("保存成功");
                            app.flow=[{},{},{},{},{},{},{},{}];
                            }
                        }
                    });}
                });  }
        },
        created(){
            load();
        }
    });
    $("#bool").load("../ming.html");
</script>

</body> 
 
</html>